# # import cv2
# # import numpy as np
# # lena = cv2.imread("lena.bmp",0)
# # cv2.imshow("lena",lena)
# # r,c  = lena.shape
# # mask = np.zeros((r,c),dtype=np.uint8)
# # mask[220:400,250:350]=1
# # key = np.random.randint(0,256,size=[r,c],dtype=np.uint8)
# # lenaXorKey = cv2.bitwise_xor(lena,key)
# # encryptFace=cv2.bitwise_and(lenaXorKey,mask*255)
# # noFace1 = cv2.bitwise_and(lena,(1-mask)*255)
# # maskFace=encryptFace + noFace1
# # cv2.imshow("maskFace",maskFace)
# # extractOriginal =cv2.bitwise_xor(maskFace,key)
# # extractFace = cv2.bitwise_and(extractOriginal,mask*255)
# # noFace2 = cv2.bitwise_and(maskFace,(1-mask)*255)
# # maskFace=encryptFace+noFace1
# # cv2.imshow("maskFace",maskFace)
# # extractOriginal = cv2.bitwise_xor(maskFace,key)
# # extractFace=cv2.bitwise_and(extractOriginal,mask*255)
# # noFace2 = cv2.bitwise_and(maskFace,(1-mask)*255)
# # extractLena = noFace2+extractFace
# # cv2.imshow("extractLena",extractLena)
# # cv2.waitKey()
# # cv2.destroyAllWindows()
#
# import cv2
#
# # 读取图像
# image_path = "a2.png" # 替换为你的图片路径
# img = cv2.imread(image_path)
#
# # 确保图像为灰度图像
# if len(img.shape) == 3:
#     img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
#
# # 定义对比度增强因子
# contrast_factor = 1.5
#
# # 使用OpenCV的convertScaleAbs函数进行线性变换
# # 这里，alpha参数决定增益，beta参数决定偏置
# enhanced_img = cv2.convertScaleAbs(img, alpha=contrast_factor, beta=0)
#
# # 显示原图和增强后的图像
# cv2.imshow("Original Image", img)
# cv2.imshow("Enhanced Image", enhanced_img)
#
# # 等待用户按键，按任意键关闭窗口
# cv2.waitKey(0)
# cv2.destroyAllWindows()

import cv2
import numpy as np

img = cv.imread("spider.png")
k = np.ones((5,5),np.uint8)
cv2.imshow("img",img)
dst =cv2.morphologyEx(img,cv2.MORPHOLOGY_TOPHAT,k)
cv2.imshow("dst",dst)
cv2.waitKey()
cv2.destroyAllWindows()
